home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / pcpil / pidoc1.txt < prev    next >
Text File  |  1994-03-01  |  39KB  |  966 lines

  1. PC/PILOT LANGUAGE REFERENCE MANUAL - Version 3.0
  2.  
  3. Notice: On your PC/PILOT diskette is a text file named README, with 
  4. additional documentation  you need. Use the DOS command TYPE README to 
  5. display it. 
  6.  
  7. Washington Computer Services, Bellingham, Washington, U.S.A. 
  8.  
  9. COPYRIGHT NOTICE
  10.  
  11. This manual and the PC/PILOT program COPYRIGHT 1985-1994 Larry Kheriaty 
  12.  
  13. DISCLAIMER NOTICE
  14.  
  15. No warrantees are made with respect to the adequacy of the software for any 
  16. particular purpose. 
  17.  
  18. Contents
  19.  
  20. Chapter 1. Using PILOT
  21.         Learning the PILOT Language . . . 1-1
  22.         How to Install PILOT . . . 1-1
  23.         System Requirements . . . 1-2
  24.         Sample Programs . . . 1-2
  25.         How to Write a Program . . . 1-2
  26.         How to Print a Program . . . 1-3
  27.         How to Run a Program . . . 1-3
  28.         PILOT Program Sizes . . . 1-4
  29.  
  30. Chapter 2. PILOT Statements
  31.         PILOT Statements . . . 2-1
  32.         Statement Labels . . . 2-2
  33.         Modifiers . . . 2-3
  34.         Conditionals . . . 2-4
  35.         Accept . . . 2-6
  36.         Compute . . . 2-12
  37.         Dimension . . . 2-17
  38.         End . . . 2-20
  39.         File . . . 2-21
  40.         Graphics . . . 2-28
  41.         Jump . . . 2-37
  42.         Keep Records . . . 2-41
  43.         Link . . . 2-42
  44.         Match . . .  .2-43
  45.         New Character . . . 2-48
  46.         New Height . . . 2-50
  47.         New Font . . . 2-51
  48.         New Key . . . 2-55
  49.         Problem . . . 2-56
  50.         Poke, Out . . . 2-59
  51.         Remark . . . 2-60
  52.         Sound . . . 2-61
  53.         Type . . . 2-62
  54.         Type Screen . . . 2-67
  55.         Use . . . 2-77
  56.         Video . . . 2-78
  57.         Wait . . . 2-80
  58.         Execute Indirect . . . 2-81
  59.  
  60. Chapter 3. Operators and Expressions
  61.         Data Types . . . 3-1
  62.         Variables . . . 3-2
  63.         Subscripting . . . 3-3
  64.         Numeric Constants . . . 3-6
  65.         String Constants . . . 3-7
  66.         Operators . . . 3-8
  67.         Functions . . . 3-9
  68.                                                   
  69. Chapter 4. GOTO and Escape Commands
  70.         GOTO Command . . . 4-1
  71.         Escape Command . . . 4-1
  72.  
  73. Chapter 5. Error Messages . . . 5-1
  74.  
  75. Chapter 6. Distributing Programs . . . 6-1
  76.                                                     
  77. Chapter 7. EZ Editor
  78.         EZ Function Keys . . . 7-1
  79.         Using the Pick Stack in EZ . . . 7-3
  80.         Search and Replace . . . 7-4
  81.         Macros in EZ . . . 7-4
  82.         Extended Characters in EZ . . . 7-5
  83.         Character Editor . . . 7-6
  84.         Select Mode . . . 7-8
  85.         Grid Mode . . . 7-8
  86.         How to Write a Macro for EZ . . . 7-10
  87.  
  88. Chapter 8. Sprites
  89.         Sprites . . . 8-1
  90.         How to Create and Edit Sprite Tables . . . 8-4
  91.         Using Sprites in a PILOT Program . . . 8-11
  92.         Sprite Commands . . . 8-13
  93.         Sprite Examples . . . 8-16
  94.  
  95. Chapter 9. PILOT Tutorial . . . 9-1
  96.  
  97. Chapter 10. Font Editor           
  98.         Using the Font Editor . . . 10-2
  99.         Main Menu . . . 10-2
  100.         Select Mode . . . 10-3
  101.         Fat-Bits Mode . . . 10-5
  102.         Changing Global Parameters . . . 10-10
  103.  
  104. Appendix A: PILOT Language Summary . . . A-1
  105.  
  106. Appendix B: PILOT Character Set . . . B-1
  107.  
  108. Appendix C: Student Records . . . C-1
  109.  
  110.  
  111.  
  112. Chapter 1. USING PILOT
  113.  
  114. This chapter explains how to install and operate PILOT. 
  115.  
  116. LEARNING THE PILOT LANGUAGE
  117.  
  118. For the person unfamiliar with programming, a beginner's tutorial is found in 
  119. chapter 10 of this manual. For the person already familiar with programming 
  120. chapter 2 describes the various statements of the language. 
  121.  
  122. Appendix C lists various other resources that may be helpful in learning and 
  123. using PILOT effectively.  
  124.  
  125. Regardless of your particular level of expertise, the first step to take is 
  126. to install PILOT according to the instructions found below. 
  127.  
  128. HOW TO INSTALL PILOT
  129.  
  130. PILOT requires no special installation. All you need to do is make a working 
  131. copy of the PILOT distribution diskette, then store the original in a safe 
  132. place. You can make a working diskette by following these steps: 
  133.  
  134.        1. Boot DOS, if not already running 
  135.        2. Place a blank diskette in drive B: 
  136.        3. Enter the command   FORMAT B:
  137.        4. Place the PILOT diskette in drive A:
  138.        5. Enter the command  COPY *.* B: 
  139.  
  140. If you have a fixed disk you should create a directory  called \PILOT,then 
  141. copy all files from the PILOT diskette to that  directory.  
  142.  
  143. When working with PILOT place a working copy of the diskette in the current 
  144. default disk drive.  (On a fixed disk, change to the \PILOT directory.) If 
  145. you need more space on your working diskette, you can remove all the sample 
  146. programs by the command ERASE SAMPLE*.PIL .  
  147.  
  148. SYSTEM REQUIREMENTS 
  149.  
  150. PILOT works best if you have at least 256K bytes of memory. Although PILOT 
  151. will run on a 128K system, program size and the use of some memory-intensive 
  152. features will be restricted.  
  153.  
  154. Although PILOT operates on either a monochrome or color video adapter, many 
  155. of PILOT's graphics features are available only on a color video adapter.  
  156.  
  157. SAMPLE PROGRAMS
  158.  
  159. Several sample programs are provided on your PILOT diskette.  Each one has a 
  160. file name of the form SAMPLEn.PIL. n represents a number.  
  161.  
  162. You can run a sample program by entering: 
  163.  
  164.        PI  SAMPLEn
  165.   
  166. Some of the samples are very simple. Others demonstrate fairly advanced 
  167. programming techniques.  Run each program and observe the results. Then 
  168. examine the program file to see how the program was written and to obtain 
  169. examples of various types of statement sequences.  
  170.  
  171. Particularly useful is SAMPLE1.PIL.  It allows you to enter PILOT statements 
  172. one at a time. Each statement is executed immediately as it is entered.  This 
  173. can help you to try out various PILOT features quickly without writing a 
  174. program.  
  175.  
  176.  
  177. HOW TO WRITE A PROGRAM
  178.  
  179. A PILOT program is a text file which contains a series of PILOT STATEMENTS. 
  180. Programs are written using a text editor to create the text file and stored 
  181. on disk under a name of your choosing.  
  182.  
  183. Included with PILOT is the EZ editor. It is designed to be simple to use 
  184. while providing several special features to aid in PILOT programming. The EZ 
  185. editor is described in a later section of this document.  Since PILOT 
  186. programs are text files, you can use any other text editors or word 
  187. processors that operate on DOS text files.  
  188.  
  189. When you write a PILOT program, you must give it a name of the form name.PIL, 
  190. where name is any word you choose. .PIL is called the file type and 
  191. identifies the file as a PILOT program.  
  192.  
  193.  
  194. HOW TO PRINT A PROGRAM  
  195.  
  196. To list the names of all PILOT programs in the current disk and directory use 
  197. the DOS command: 
  198.  
  199.        DIR  *.PIL 
  200.  
  201. To list a program on the screen use the DOS command: 
  202.  
  203.        TYPE  name.PIL 
  204.  
  205. To print the listing on your printer, first ready the printer, then enter the 
  206. command: 
  207.  
  208.        COPY  name.PIL  PRN: 
  209.  
  210.  
  211. HOW TO RUN A PROGRAM 
  212.  
  213. To begin execution of a PILOT program enter: 
  214.  
  215.        PI  name 
  216.  
  217. where name.PIL is the path name of the file which contains the PILOT program 
  218. to be run. The suffix of ".PIL" is appended automatically by PILOT. You 
  219. should not type it when entering the file name.  
  220.  
  221. Per normal DOS conventions, you can precede the PI by an optional drive 
  222. designation if the file PI.EXE is not in the current disk drive.  
  223.  
  224. The file name can be a full DOS path name if the file is not in the current 
  225. disk or directory.  Thus the program to be run can be in any directory, any 
  226. drive, and any network node desired.  
  227.  
  228. When a program ends, control is returned to DOS.  
  229.  
  230. A program may be prematurely canceled at any time by pushing ctrl C (ie, push 
  231. the C while holding down the ctrl key).  
  232.  
  233. PILOT PROGRAM SIZES
  234.  
  235. When PILOT starts, a program buffer is set aside from the available memory. 
  236. Unless the PI command line indicates otherwise, the buffer size is 32K bytes.  
  237. You can specify another program buffer size by adding a parameter to the PI 
  238. command line as follows: 
  239.  
  240.       PI  name  n
  241.  
  242. where "n" can be a number from 1 through 8. The program buffer size is set to 
  243. n*8K bytes. A maximum value of 8 indicates a program buffer size of 64K 
  244. bytes.  If the requested amount of memory is unavailable, then a program 
  245. buffer of 8K bytes is allocated from PILOT's internal string space.  
  246.  
  247. Chapter 2. PILOT STATEMENTS
  248.  
  249. A statement follows the following general format: 
  250.  
  251. *label  op-code <modifiers/conditionals> :   arguments 
  252.  
  253. The *label is optional.  The modifiers may be coded in any order.  If a 
  254. particular modifier does not make sense for the op-code, the modifier is 
  255. ignored.  The op-code represents the type of statement to be executed.  The 
  256. op-code, modifiers and conditionals may be upper or lower case.  There may be 
  257. no spaces within the op-code, modifiers or conditionals (except within 
  258. conditional expressions).  There must be a colon after the op-code modifiers 
  259. and conditionals.  After the colon there may be further arguments.  The 
  260. format and meaning of the arguments after the colon depend on the particular 
  261. op-code.  
  262.  
  263. A PILOT program is a sequence of statements.  Each statement is written on 
  264. one line. The maximum statement length is 256 characters. A program may 
  265. consist of any number of statements, limited only by the amount of disk space 
  266. available. Programs may be created using any editor which produces standard 
  267. ascii formatted text files. It is recommended that you use the EZ editor 
  268. provided with PILOT to create your program files.  
  269.  
  270. EXAMPLE 1: A simple Type statement.
  271.  
  272.        T:Welcome to Biology 301.
  273.  
  274. See also:   STATEMENT LABELS, MODIFIERS, CONDITIONALS
  275.  
  276. STATEMENT LABELS
  277.  
  278. A statement label is preceded by a "*" character and consists of one to six 
  279. alphanumeric characters (letters and digits). A label may be alone on a line 
  280. or may precede a statement on the same line.  Upper and lower case letters 
  281. are considered equivalent within labels.  
  282.  
  283. A label serves the purpose of providing a branch point (place to jump to). 
  284. Unless instructed otherwise, PILOT runs a program by executing successive 
  285. statements in the order that they occur in the program. Using the Jump (J) 
  286. statement provides a means of altering the natural program flow by jumping 
  287. from one location within the program to another location, marked by a label.  
  288.  
  289. For efficiency, PILOT automatically optimizes label addressing for labels 
  290. that are at least two characters long. For this reason, it is recommended 
  291. that one-characters labels not be used when execution speed is important.  
  292.  
  293. EXAMPLE 1: Label as a target for a Jump; label written on same line as 
  294. statement.  
  295.  
  296.        T:We will now proceed directly to part3.
  297.        J:PART3
  298.        . . .
  299.        . . .
  300.        *PART3   T: The next question is...
  301.  
  302.  
  303. EXAMPLE 2: Label written alone on a line. 
  304.  
  305.        *REVIEW
  306.        T:Let us look again at the diagram...
  307.       
  308.  
  309. See also:  JUMP
  310.  
  311. MODIFIERS
  312.  
  313. A modifier is a letter appended to an op-code.  It causes change in the way 
  314. the statement is executed. The letters used as modifiers are H, J, S and X. 
  315. The specific meaning that a modifier takes on depends entirely on the op-code 
  316. to which it is appended. The modifier letters are used to designate 
  317. variations on the operation of the basic statement types. 
  318.  
  319. For example, the "S" modifier, when appended to the M: op code gives the 
  320. "match-spelling" statement. In this case the "S" modifier is sometimes 
  321. referred to as the "spelling" modifier.  
  322.  
  323. The same letter, S, when appended to the A: op code yields the "accept 
  324. single" statement. It modifies the normal operation of the accept statement 
  325. to input an answer of only one key rather than the normal one line. 
  326.  
  327. If a modifier (H, J, S or X) is appended to any op-code for 
  328. which the meaning is not yet defined, the modifier has no effect on the 
  329. statement. 
  330.  
  331. CONDITIONALS 
  332.  
  333. A conditional is a letter, digit or expression appended to any op-code.  The 
  334. conditional causes the statement to be executed only if the condition is 
  335. true.  If it is false, then the statement is skipped.  Each conditional is 
  336. shown below as appended to a TYPE statement, however, each can be appended to 
  337. any type of statement.  
  338.  
  339. TY: - type if last match was YES
  340.  
  341. TN: - type if last match was NO
  342.  
  343. TE: - type if error flag is true
  344.  
  345. T(exp): - type if expression is true
  346.  
  347. The expression is evaluated, if it  is true (non zero) then the statement  is 
  348. executed, otherwise it is skipped.  
  349.  
  350. TC: - type if previous expression was true
  351.  
  352. Tn: - type if accept counter=n
  353.  
  354. n may be a number from l to 9. Type if n is equal to the accept counter. The 
  355. accept counter is a value which tells how many times the last accept has been 
  356. executed in a row.  
  357.  
  358.  
  359. Any number of conditionals may be appended to the op-code.  All must be true 
  360. for the statement to be executed. If any conditional is found to be false, 
  361. the remainder of the statement is skipped over, and execution continues with 
  362. the next statement in line.  
  363.  
  364. EXAMPLE 1: Y and N conditions to test a student response for correct or 
  365. incorrect.  
  366.  
  367.        T:How many feet in a yard?
  368.        A:
  369.        M:three
  370.        TY:Correct
  371.        TN:Incorrect
  372.  
  373. EXAMPLE 2: Conditional expression and C condition to re-test same condition.  
  374.     
  375.        T(TRY < LIMIT): No, look at this.
  376.        JC: REVIEW
  377.  
  378.  
  379. EXAMPLE 3: Conditional expression used to create a loop to print digits 1 
  380. through 9.  
  381.  
  382.        C: I=1
  383.        *LOOP  TH:#I,
  384.        C:I=I+1
  385.        J(I<10):LOOP
  386.  
  387.  
  388. EXAMPLE 4: N and digit condition used in combination to give successive 
  389. hints.  
  390.  
  391.        T:What do we call an 8 sided figure?
  392.        A:
  393.        M:octagon
  394.        TY:Right
  395.        TN1:Hint: A STOP sign is one.
  396.        TN2:Hint: An octopus has eight arms.
  397.        TN3:That's your third wrong try.
  398.  
  399. EXAMPLE  5:  E condition used as a check  for  a numeric answer.  
  400.  
  401.        T:What is 4+5?
  402.        A: #N
  403.        TE:Please type a number.
  404.        JE:@A
  405.        M:9
  406.        TY:Right.
  407.  
  408.  
  409. See also:  MATCH, ACCEPT 
  410.  
  411. ACCEPT - input student response
  412.  
  413.        A:
  414.        A: $variable$ #variable
  415.        AH:
  416.        AJ:
  417.        AS:
  418.        AX:
  419.  
  420.  
  421. ACCEPT is used to input a student response.    When the ACCEPT is 
  422. encountered, PILOT waits for the student to enter an answer. The student 
  423. types a response followed by the Enter key.  While typing the response, the 
  424. student can use the Backspace key to correct typing errors. The response is 
  425. automatically edited  per the space and case options last set on a PROBLEM 
  426. statement.  These options can be used to convert answers to all upper or all 
  427. lower case, or to remove spaces from the answer. The edited response is then 
  428. placed in the system variable %B, also called the answer buffer.  
  429.  
  430. Characters typed by the student are displayed on the screen.  When the 
  431. student pushes the Enter key to end the response, the cursor is moved to the 
  432. start of the next line. However, if the H (hang) modifier is added to the 
  433. ACCEPT statement then the cursor is left hanging at the end of the student 
  434. response.  
  435.  
  436.  
  437. ANSWER LENGTH LIMIT
  438.  
  439. Unless otherwise specified, the student answer is limited to a maximum of 80 
  440. characters. The An option of the PROBLEM statement can be used to set the 
  441. answer length limit to any value from 1 to 256 characters. The answer length 
  442. limit can not be set to a value greater than 256 characters.  
  443.  
  444.  
  445. ACCEPT SINGLE
  446.  
  447. The S (single) modifier appended to the ACCEPT (AS:) limits the response to 
  448. one keystroke regardless of the current response length limit.  When the S 
  449. modifier is appended to the ACCEPT, no editing of the value is done; it is 
  450. placed in the answer buffer as a one character string.  
  451.  
  452.  
  453. USE OF KEYBOARD TYPE-AHEAD
  454.  
  455. Unless the program indicates otherwise, the student can not type the answer 
  456. prior to the program reaching the ACCEPT statement. The J modifier (AJ:) 
  457. allows type-ahead to be used for this ACCEPT. With type-ahead enabled, keys 
  458. pushed prior to the ACCEPT statement "count" as part of the reply.  
  459.  
  460.  
  461. INPUT OF SPECIAL CHARACTERS
  462.  
  463. Input characters in the range of ascii 32 to 255 are accepted as input data. 
  464. The normal Ascii character set consists of characters from 32 to 127. The 
  465. characters in the range 128 to 255 are used for the text mode extended 
  466. character set, and for user-defined characters. Appendix A contains a 
  467. complete list of the standard codes generated by each keyboard combination.  
  468.  
  469. The NX: statement can be used to change the code generated by any particular 
  470. keyboard key or combination. If the X modifier is not appended to the ACCEPT 
  471. op-code, then the values input for each key on the keyboard are affected by 
  472. previous NX: statements.  If the X modifier is appended to the ACCEPT (AX:), 
  473. then all keys generate their default standard values regardless of any 
  474. previous NX: statements.  
  475.  
  476.  
  477. STUDENT RESPONSE TIMING
  478.  
  479. Unless otherwise specified, the student can take any duration of time to 
  480. respond. However, a time limit can be set by the Tn option of the P: 
  481. statement. If the student has not pushed the Enter key within the time limit, 
  482. then PILOT proceeds as if the Enter key had been pushed.  
  483.  
  484. Whether there is a time limit or not, the built-in function TIM(0) returns 
  485. the length of time (in seconds and fractions of a second) taken by the 
  486. student to respond to the last ACCEPT.  
  487.  
  488.  
  489. SETTING VARIABLES
  490.  
  491. One or more string or numeric variables may be placed after the colon on an 
  492. ACCEPT.  Each variable name must be preceded by a $ or a #.  For each string 
  493. variable, the value of the answer buffer is assigned to the string.  For each 
  494. numeric variable, the first number found in the answer buffer is assigned to 
  495. the variable.  If more than one numeric variable is written, each variable is 
  496. set to the same value.  
  497.  
  498. If a numeric variable is included on the ACCEPT statement, and no number is 
  499. found in the student answer, the E condition is set to true. By checking the 
  500. E condition after the ACCEPT statement, it is possible to determine whether a 
  501. numeric reply was given.  
  502.  
  503.  
  504. THE GOTO COMMAND
  505.  
  506. If the G option has been enabled on a previous PROBLEM statement, the student 
  507. can enter a GOTO command rather than an answer. To do so, the student must 
  508. type: 
  509.  
  510.        GOTO label 
  511.  
  512. The label typed by the student must correspond to a label within the program. 
  513. Naturally, this is of use to the student only if the student has been 
  514. instructed as to the possible labels to go to.  Usually, the GOTO command is 
  515. most useful to the program author when debugging or testing the program.  It 
  516. would allow the author to test various sections of the program, skipping over 
  517. other sections not of interest.  
  518.  
  519.  
  520. ESCAPE FEATURES
  521.  
  522. Often it is desirable to allow the student to push certain function keys or 
  523. escape keys to cause pre-defined actions to take place. These actions might 
  524. be a return to a menu, review of a previous question, a help screen, a 
  525. glossary, etc. In many cases you wish the student to be able to use these 
  526. special keys at any time that the student is expected to reply. It would be 
  527. inconvenient to place the necessary statements to do the special key checking 
  528. at every answer point. So PILOT provides for automatic checking of special 
  529. "hot" keys.  
  530.  
  531. There are two possible levels of key checking available. The E option on the 
  532. PROBLEM statement indicates that the ESCAPE key and the @ key are to be 
  533. trapped. The F option on the PROBLEM statement indicates that the function 
  534. keys, the shifted function keys, and the cursor keypad keys are all to be 
  535. trapped. The program can enable either, both or neither of these options.  
  536. All special keys (except the @ key) are trapped immediately when pressed by a 
  537. student responding to an ACCEPT statement. The @ key is only trapped when 
  538. entered as the first character of a response, and only after the ENTER key 
  539. has been pushed. (The use of the @ key is retained only for compatibility 
  540. with older versions of PILOT.) 
  541.  
  542. When one of the special keys is detected by the ACCEPT statement, the 
  543. following actions take place.  
  544.  
  545.        1. The key value is placed in the answer 
  546.        buffer, %B, after any previously typed
  547.        characters.
  548.  
  549.        2. The ACCEPT statement is immediately halted.
  550.  
  551.        3. PILOT performs the equivalent to the line
  552.        U:SYSX
  553.        That is, it calls the subroutine named
  554.        *SYSX in the current program.
  555.  
  556. It is up to the programmer to insure that there is a label *SYSX in the 
  557. program.  The *SYSX routine can determine exactly which special key was 
  558. pressed by: 
  559.  
  560.        C: F = ASC(%B(LEN(%B))
  561.  
  562. which would set the variable F to the value 27 for the Escape key, or a value 
  563. from 187 to 221 for one of the function or cursor keys. Appendix A contains a 
  564. complete listing of the codes generated by the various keys. Note that if you 
  565. wish to change the set of keys that are trapped, you can use the NX: 
  566. statement to change the codes received by the various keys. When the effects 
  567. of NX: statements are taken into account, any keys in the range 187 to 221 
  568. are trapped; any other keys are not.  
  569.  
  570. Once control is passed to the SYSX subroutine, it is up to the program to 
  571. implement whatever action is to take place. At the end of the SYSX 
  572. subroutine, the program could return to re-execute the ACCEPT via: 
  573.  
  574.        E:@A
  575.  
  576. The subroutine can also branch off to another location in the program by a 
  577. statement such as: 
  578.  
  579.        E:MENU3
  580.  
  581. ACCEPT EXAMPLES
  582.  
  583. EXAMPLE 1: simple answer input
  584.  
  585.        T:What is the capital of Norway?
  586.        A:
  587.  
  588. EXAMPLE 2: accept numeric answer
  589.  
  590.        A: #X
  591.        TE: I need a number.  Try again.
  592.        JE: @A           
  593.  
  594. EXAMPLE 3: accept a fill-in-the blank answer
  595.   
  596.        TS:G0,10
  597.        TH:Mary had a        lamb.
  598.        TS:G11,10
  599.        P:A7     
  600.        AH:
  601.  
  602. EXAMPLE 4: input any one key
  603.  
  604.        AS:
  605.        T: The key value is #(ASC(%B))
  606.   
  607. EXAMPLE 5: input a timed response
  608.  
  609.        P:T5
  610.        TH: 6 x 8 = 
  611.        A:
  612.        T:You took #(TIM(0))  seconds.
  613.  
  614. See also:  PROBLEM, NX:, GOTO AND ESCAPE
  615.  
  616.  
  617. COMPUTE - assignment statement
  618.  
  619.        C: target = expression
  620.        C: target = expression ; target = expression ;
  621.        C: target = expression  \ remarks
  622.  
  623. The COMPUTE statement is used to perform numerical computations, or to 
  624. perform string manipulation. Any number of assignments may be made on one 
  625. compute line by separating each from the previous by a semi-colon. A remark 
  626. or comment may be placed after the assignments by preceding the remark with a 
  627. back-slash, "\".  
  628.  
  629. Numerical computations consist of operations such as addition, subtraction, 
  630. multiplication, and division.  
  631.  
  632. String manipulation consists of operations on character strings, such as 
  633. capitalization, picking a word out of a sentence, or combining several words 
  634. into a sentence.  
  635.  
  636. A COMPUTE statement always contains an = sign.  On the right of the equal 
  637. sign is an expression.  A complete discussion of expressions may be found in 
  638. a later section of this manual.  However, in general, an expression is a 
  639. series of numeric or string operations to be performed which result in a 
  640. value.  The resultant value can be a number, or it can be a character string.  
  641.  
  642. On the left side of the = sign is a target variable.  The target may be a 
  643. numeric variable, a subscripted array variable, a string variable, a 
  644. subscripted string variable, or the system variables %B or %A.  
  645.  
  646. The COMPUTE statement evaluates the expression, then assigns, or sets, the 
  647. target to the resultant value.  
  648.  
  649. ASSIGNMENT TO NUMERIC VARIABLE
  650.  
  651. A variable that has not been explicitly made to be a string or array is 
  652. called a numeric variable or a simple variable. Such a variable stores a 
  653. single numeric value. If the target of the COMPUTE is a numeric variable, 
  654. then the expression is expected to yield a number when evaluated. The number 
  655. value is stored in the variable, replacing any previous value the variable 
  656. had. If the expression happens to produce a string value rather than a 
  657. numeric value, PILOT automatically converts the string value into a numeric 
  658. value, then assigns the numeric value to the the variable. To convert the 
  659. string value to a numeric value, PILOT takes the first number found in the 
  660. string, searching from the left. If there is no number in the string, the 
  661. numeric value is zero.  
  662.  
  663. The system variable %A, which contains a count of the number of times the 
  664. current ACCEPT statement has been responded to, is considered to be a numeric 
  665. variable.  It can be used in an expression or can be the target of the 
  666. COMPUTE.  
  667.  
  668. EXAMPLE 1: assignment to numeric variable
  669.  
  670.        C: X = 5 + 4                         sets X to 9
  671.        C: X = X / 2                         sets X to 4.5
  672.        C:AGE="I am 14 years old"            sets AGE to 14
  673.        C: X=1 ; Y=2 ; Z=3                   sets 3 variables
  674.  
  675. ASSIGNMENT TO SUBSCRIPTED VARIABLE
  676.  
  677. An array variable is a variable name which represents a list of numeric 
  678. values. The DIMENSION statement is used to create an array variable. An 
  679. individual item within an array can be identified by placing the number of 
  680. the item in parentheses after the array variable name.  The number in the 
  681. parentheses is called a subscript. Array items are numbered from 0, for the 
  682. first item in an array, to the number specified in the Dimension statement 
  683. which created the array.  Each item in an array can be thought of as a 
  684. numeric variable.  The only difference is that a variable is identified by 
  685. its own unique name, whereas an array item is identified by both an array 
  686. name and a subscript. Assignment to an item within an array is similar to 
  687. assignment to a numeric variable.  
  688.  
  689. EXAMPLE 2: assignment to the items in an array
  690.  
  691.        D:Z(3)        
  692.        C:Z(0) = 100  
  693.        C:Z(1) = 200  
  694.        C:Z(2) = 300  
  695.        C:Z(3) = 1000 
  696.  
  697. ASSIGNMENT TO A STRING VARIABLE
  698.  
  699. A string variable is a variable which can store a character string. A 
  700. character string is a list of characters, such as "ABC", "Banana", or "The 
  701. Declaration of Independence". A string variable name always ends with a "$". 
  702. Also, before a string variable can store a string value, the DIMENSION 
  703. statement must be used to set aside space for the string variable. When a 
  704. string variable is created by the DIMENSION statement you must specify the 
  705. number of characters, or bytes, to be set aside for the string variable.  
  706. This number is called the maximum length of the string variable. At any time, 
  707. the string variable may store any number of characters from 0 to its maximum 
  708. length. The number of characters stored in a string at any particular time is 
  709. called the current length. A string which contains no characters at all is 
  710. called a null string. A null string has a length of zero.  
  711.  
  712. The system variable %B, which always contains the response given by the 
  713. student at the last ACCEPT statement, is a string variable with a maximum 
  714. length of 80 characters. It can be used in an expression or as the target of 
  715. a COMPUTE.  
  716.  
  717. When the target is a string variable the expression is expected to yield a 
  718. string value.  If it happens to yield a numeric value, then PILOT 
  719. automatically converts the numeric value to a string value by creating a 
  720. string which represents what the numeric value would look like if printed out 
  721. on the screen.  It may seem odd to distinguish between a string value of 
  722. "123.45" and a numeric value of 123.45; it is only within computers that such 
  723. distinctions matter at all. PILOT frees you from being concerned with this 
  724. distinction by automatically converting to the form needed to fit the 
  725. context.  
  726.  
  727. The expression value is assigned to the string variable, replacing any 
  728. previous value the string variable may have had.  If the expression value is 
  729. longer than the maximum length of the string variable, then the value is 
  730. truncated (cut off on the right end) to the maximum length of the string 
  731. variable.  After the assignment, the current length of the string variable 
  732. will be the number of characters actually assigned to the string variable.  
  733.  
  734. EXAMPLE 3: assignment to string variables
  735.  
  736.        D: DAY$(10)
  737.        C: DAY$ = "TUESDAY"
  738.        C: DAY$ = "Sun Oct 6, 1950"
  739.  
  740. The last statement above results in variable DAY$ set to "Sun Oct 6," since 
  741. its maximum length is 10.  
  742.  
  743. ASSIGNMENT TO A SUBSCRIPTED STRING
  744.  
  745. A string variable can be thought of as storing a list of characters or bytes. 
  746. It is possible to refer to a piece of a string, sometimes called a substring. 
  747. To do so, place subscripts after the string variable name within parentheses. 
  748. You can refer to one character within a string by placing one subscript after 
  749. the string variable.  The characters within a string are numbered from 1 (for 
  750. the first character) to the current length of the string. To refer to several 
  751. characters within a string, you place two subscripts in parentheses, 
  752. separated by a comma.  The first subscript denotes the starting position 
  753. within the string, the second denotes the number of characters in the 
  754. substring. If the second subscript is omitted, the length of the substring
  755. is 1.  
  756.  
  757. There are a few rules about what happens if you specify a target substring 
  758. with a starting position and length which are out of the bounds of the 
  759. current string length: 
  760.  
  761. (1) Since the first position of a string is position 1, if you specify a 
  762. position less than 1, then  PILOT assumes you mean position 1.  
  763.  
  764. (2) If you give a position greater than the current length of the string 
  765. variable, then PILOT expands the string variable as necessary by adding 
  766. blanks to the end of it.  
  767.  
  768. (3) If you give a position greater than the maximum length of the string, 
  769. PILOT assumes you mean to position at the last character of the string.  
  770.  
  771. (4) If you specify a length which would go over the end of the string, the 
  772. substring goes only to the end of the string.  
  773.  
  774. The result of an assignment to a substring is determined by several factors: 
  775. the length of the expression value to be assigned, the current and maximum 
  776. length of the string variable, and the values of the subscripts after the 
  777. string variable name.  
  778.  
  779. To assign a value to a subscripted string variable the expression value is 
  780. computed, if it is a number it will be converted to a string.  Then, if the 
  781. string value is longer than the substring to which it is being assigned, it 
  782. is truncated (cut off from the right end) to the appropriate length. If the 
  783. expression value is shorter than the substring to which it is being assigned, 
  784. the value is padded on the right end to the appropriate length by appending 
  785. spaces.  
  786.  
  787. EXAMPLE 4: assignment to substrings
  788.  
  789.        D: X$(10)
  790.                                        (creates string X$)
  791.        C: X$(10) = " "
  792.                                        (sets X$ to 10 spaces)
  793.        C: X$ = "ABCDEFGHIJ"
  794.                                        (X$ now "ABCDEFGHIJ")
  795.        C: X$(4) = "d"
  796.                                        (X$ now "ABCdEFGHIJ")
  797.        C: X$(3,5) = "xzy"
  798.                                        (X$ now "ABxyz  HIJ")
  799.        C: X$(9,5) = "QRSTUV"
  800.                                        (X$ now "ABxyz  HQR")
  801.  
  802. DIMENSION - allocate arrays and strings
  803.  
  804.  
  805.        D: variable (size), . . .
  806.        DX: variable (size), . . .
  807.  
  808. DIMENSION creates an array of numbers or a character string.  If the variable 
  809. name ends with the "$" character a string is created, otherwise an array is 
  810. created.  Any number of arrays or strings can be created in one DIMENSION 
  811. statement by separating each variable and size from the next by a comma.  
  812.  
  813. If an array or string has been created previously in the program, then an 
  814. attempt to dimension the same variable again will first cause the previous 
  815. contents of the array or string to be discarded. Then the new array or string 
  816. is created as if for the first time.  You should normally place all the 
  817. DIMENSION statements for a program toward the beginning of the program, in 
  818. such a place that they will be executed only once.  
  819.  
  820. DIMENSION OF A NUMERIC ARRAY
  821.  
  822. An array is a list of numeric values. Each value can be accessed by the array 
  823. name, followed by a subscript. A subscript is a numeric value in parentheses. 
  824. The DIMENSION statement sets aside enough space to hold the specified size, 
  825. plus one.  
  826.  
  827. The first item in an array is accessed by a subscript of 0, the next by a 
  828. subscript of 1, and so on. The last item in an array is accessed by a 
  829. subscript equal to the size value given on the DIMENSION statement. When an 
  830. array is created via the DIMENSION statement, we sometimes say that the 
  831. variable has been "dimensioned" to a particular size. When an array is 
  832. created, the various numeric values in the array are not automatically 
  833. initialized to any particular value. The initial value of any particular 
  834. array item might be any number.  
  835.  
  836. DIMENSION OF A STRING VARIABLE 
  837.  
  838. If the variable name ends with a "$", then a string variable is created. A 
  839. string variable stores a character string or a list of characters. The size 
  840. given in the DIMENSION statement indicates the amount of memory set aside for 
  841. the string variable and the maximum length character string that can be 
  842. stored in the string variable. At any time the string variable can store any 
  843. string up to the maximum string length.  The number of characters stored in a 
  844. string at any particular moment is called the current length of the string.  
  845.  
  846. An individual character position in a string variable can be accessed by a 
  847. subscript. The first position of a string has subscript 1. When a string 
  848. variable is created, it is initially set to a null string (i.e. a string with 
  849. no characters in it). If you then wish to fill the string to its maximum 
  850. length use a COMPUTE statement to assign a blank to the last character 
  851. position. For example: 
  852.  
  853.        D: XYZ$(3500)
  854.        C: XYZ$(3500) = " "
  855.  
  856. SPECIAL USES OF STRING VARIABLES
  857.  
  858. There are several special purposes for string variables. One is to store a 
  859. machine language subroutine to be called via the V: statement. If a string is 
  860. to be used for this purpose, then you must append the X modifier to the D: op 
  861. code when creating the string. This forces 16-byte memory alignment of the 
  862. string start. This factor is only important for machine language programming 
  863. due to the nature of the processor chip, and segment register limitations.  
  864.  
  865. The second special purpose for a character string is to hold a sprite table. 
  866. A string to be used for this purpose must be created with a size of at least 
  867. 2218 characters. A complete explanation of this feature is contained in the 
  868. sprite section of this manual.  
  869.  
  870. ARRAY AND STRING SPACE CAPACITY
  871.  
  872. PILOT sets aside approximately 35,000 bytes of space for storage of arrays 
  873. and strings. The amount may be less if the computer memory is less than 256K 
  874. bytes.  Each array takes up 4 bytes per array item. Each string takes up one 
  875. byte per string position. The same pool of space is used for scratch pad 
  876. during various string manipulation operations, so if you get space error 
  877. messages on a statement other than a dimension, you need to leave more space 
  878. for scratch purposes.  
  879.  
  880. EXAMPLE 1: Create a numeric array with items numbered from 0 to 100.  
  881.  
  882.        D: LIST(100)
  883.  
  884. EXAMPLE 2: Create a string to store the student's name.  
  885.  
  886.        D:NAME$(30)
  887.        T:What is your name?
  888.        A:$NAME$
  889.  
  890. EXAMPLE 3: Create a string to hold a machine language subroutine, and read 
  891. the subroutine from disk into the string. 
  892.  
  893.        DX: VEZ$(6000)
  894.        FX:VEZ.BIN
  895.        FI:0,VEZ$
  896.  
  897. EXAMPLE 4: Create a string to hold a sprite table, and read the sprite table 
  898. from disk into the string. 
  899.  
  900.        D:SPRI$(2218)
  901.        FX:PLANETS.SPR
  902.        FI:0,SPRI$
  903.  
  904. EXAMPLE 5: Create two string variables and three arrays in one statement.  
  905.  
  906.        D: X$(20), Z$(340), A(100), B(200), C(3)
  907.  
  908. See also:  SUBSCRIPTING
  909.  
  910. END - terminate subroutine or program
  911.  
  912.        E:
  913.        E: destination
  914.  
  915. The END statement has two purposes. First, if the use stack is empty, meaning 
  916. that there is no un-ended USE in effect, then the END statement terminates 
  917. the program and returns to DOS.  
  918.  
  919. Second, if the use stack is not empty, meaning that there is an un-ended USE 
  920. statement in effect, the END statement pops the top entry off the use stack. 
  921. This entry indicates the return point for the associated USE statement. The 
  922. return point is the statement following the USE statement. If the END 
  923. statement does not have a destination operand after the colon, then END jumps 
  924. to the return point. If the END statement does have a destination after the 
  925. colon then (after popping the entry off the use stack) END jumps to the label 
  926. indicated on the END statement. This feature allows a subroutine called via 
  927. the USE statement to return to either the statement after the USE or to 
  928. another point in the program. This is particularly useful in conjunction with 
  929. the ESCAPE command. The SYSX subroutine might be called from many places but 
  930. might always exit to a menu or other common return point.  
  931.  
  932. See also:  USE, GOTO AND ESCAPE
  933.  
  934. EXAMPLE 1: END which always returns to DOS
  935.  
  936.        *QUIT  E:QUIT
  937.  
  938. EXAMPLE 2: END used to return from a subroutine
  939.  
  940.        *SUB T:Metric Conversion Table
  941.        . . .
  942.        E:
  943.  
  944. FILE - access external or heap file
  945.  
  946.        FX: filename
  947.        FX:
  948.        FI: position-expression,variable$
  949.        FO: position-expression,value-expression
  950.  
  951.        FXH: heapsize
  952.        FIH: position-expression,variable$
  953.        FOH: position-expression,value-expression
  954.  
  955. The FILE statement provides access to disk files, the printer or auxiliary 
  956. (RS-232 serial) port, a network or an in-memory file called the heap. To 
  957. access a file, the program must first open the file. To open a file use the 
  958. FX: statement. PILOT allows one open file at a time.  Whenever you open a 
  959. file, PILOT will close any previously opened file. The FX: statement without 
  960. a filename after the colon, closes an open file without opening another file.  
  961.  
  962. Once a file is opened, the FI:, FILE IN statement, is used to read data from 
  963. the file into a string variable. The FO:, FILE OUT statement, is used to 
  964. write data from the program to the file.  
  965.  
  966.